export default {
	data() {
		return {
			choose: 0,
			addressList: []
		};
	},
	onLoad(options) {
		this.choose = options.choose
	},
	onShow() {
		this.getAddrList()
	},
	methods: {
		// 获取地址列表
		async getAddrList() {
			var res = await this.$get('server/index/addressList', {
				id: this.goodsId,
			});
			if (res.errcode != 0) {
				this.$toast(res.errmsg);
				return;
			}
			this.addressList = res.list
		},
		// 点击编辑
		onEdit(item) {
			this.$navTo('pages/mine/address-edit/address-edit', {
				addr: item.id
			})
		},
		// 选择地址
		onChoose(item) {
			console.log('choose----', this.choose)
			if (!this.choose) return;
			uni.$emit('chooseAddr', {
				addr: item
			});
			uni.navigateBack();
		},
		// 新增地址
		addAddr() {
			this.$navTo('pages/mine/address-edit/address-edit')
		}
	}
}
